<?php
include("../../inc/global.inc");
include("islogin.php");
$id = intval($_GET['id']);
$head['title']='托管交易-打款';	
$row=$db->get_one("SELECT * FROM `sd_tuoguan` WHERE id=$id and status!=2 and userid=".$per_row['id']);
if(!$row){
 echo "<script>location='/err.html';</script>";
}
if(isset($_POST['submit']) && $_POST['submit'])
{
	$array = $_POST['info'];
	
	$array['inputtime']=time();
	$array['updatetime']=time();
	$array['ip']=ip();
	$array['userid']=$per_row['id'];
	$array['userid2']=$row['userid2'];
	$array['username']=$per_row['m_user'];
	$array['username2']=$row['username2'];
	
	$true = $db->insert('sd_dakuan', $array);
	if($true)
	{
		$array2['status'] = 2;
		$db->update('sd_tuoguan', $array2,"id=".$_POST['info']['tuoguanid']." and userid=".$per_row['id']);
		echo "<script>alert('汇款信息添加成功');location='/member/tuoguan/guanli.php?fukuan=1';</script>";exit;
	}
	else
	{
		echo "<script>alert('汇款失败，未知原因。请联系管理员');location='".HTTP_REFERER."';</script>";exit;
	}
}
$yinhhang = $db->get_one("select * from sd_yinhang where userid=".$per_row['id']);
if(!$yinhhang){echo "<script>location='/member/tuoguan/tuoguantongguo1.php?id=$id';</script>";exit;}
include("top.php");
?>
<div class="con">
		   <div class="top5"><span>您当前位置：<a href="/help/">会员助手</a> &gt;&gt; <?php echo $head['title'];?></span></div>
		   <?php include("left.php");?>
		   <div class="right">
		      <div class="y_5"></div>
		       <div class="con-tt"><span>汇款后银行信息</span></div>
			   <div class="con-t1"><span> 请您在汇款后及时提交您汇款金额和您汇的银行。</span></div>
			   <div class="con-t2"><form action="" method="post" onsubmit="return check();">
               		<input type="hidden" name="info[tuoguanid]" value="<?php echo $id;?>" />
					<table width="100%" border="0" cellpadding="0" cellspacing="0" >
	                 <tr>
		                <td width="20%" height="30" align="center" bgcolor="#EFF6FF"> 汇款银行名称：</td>
	                <td colspan="2" bgcolor="#f9f9f9"><input name="info[bankname]" type="text" class="txt1" id="bankname"/> </td>                     
					</tr>
					<tr>
		                <td width="20%" height="30" align="center" bgcolor="#EFF6FF"> 汇款时间：</td>
	                <td colspan="2" bgcolor="#f9f9f9"><input name="info[dtime]" type="text" class="txt5" value="<?php echo date('Y-m-d H:i:s');?>" id="dtime"/> </td>                     
					</tr>
	                 <tr>
		                <td  height="30" align="center" bgcolor="#EFF6FF">汇款金额：</td>
		                <td colspan="2" bgcolor="#f9f9f9"><input name="info[price]" type="text" class="txt1" id="price"/>元</td>
	                </tr>
	                 <tr>
		                <td height="160" bgcolor="#EFF6FF" align="center">备注：</td>
		                <td width="79%" bgcolor="#f9f9f9"><input name="info[content]" type="text" class="txt9" value="" id="content"/></td>
                    </tr>
	                 <tr>
		                <td height="45" bgcolor="#EFF6FF">&nbsp;</td>
		                <td colspan="2" bgcolor="#f9f9f9">&nbsp;
						<input name="submit" type="submit" id="submit" value=" 提交" class="btn1"/></td>
	                </tr>
                 </table></form>
               </div>
		 </div>
		 <div class="cl"></div>
</div> 
<?php include("foot.php");?>
<script>
	function check()
	{
		if($('#bankname').val()=='')
		{
			alert('请输入汇款银行名称');
			$('#bankname').focus();
			return false;
		}
		if($('#dtime').val()=='')
		{
			alert('请输入汇款时间');
			$('#dtime').focus();
			return false;
		}
		if($('#price').val()=='')
		{
			alert('请输入汇款金额');
			$('#price').focus();
			return false;
		}
		if($('#content').val()=='')
		{
			alert('请输入备注');
			$('#content').focus();
			return false;
		}
	}
</script>
